import request from '@/utils/request'

// 查询知识映射列表
export function listKnowledgeMapping(query) {
  return request({
    url: '/data/knowledge_mapping/list',
    method: 'get',
    params: query
  })
}

// 查询知识映射详细
export function getKnowledgeMapping(id) {
  return request({
    url: '/data/knowledge_mapping/' + id,
    method: 'get'
  })
}

// 新增知识映射
export function addKnowledgeMapping(data) {
  return request({
    url: '/data/knowledge_mapping',
    method: 'post',
    data: data
  })
}

// 修改知识映射
export function updateKnowledgeMapping(data) {
  return request({
    url: '/data/knowledge_mapping',
    method: 'put',
    data: data
  })
}

// 删除知识映射
export function delKnowledgeMapping(id) {
  return request({
    url: `/data/knowledge_mapping/${id}`,
    method: 'delete'
  })
}

// 根据结构ID获取知识映射
export function getKnowledgeMappingsByStructId(structId) {
  return request({
    url: '/data/knowledge_mapping/struct/' + structId,
    method: 'get'
  })
}

// 根据结构ID和需求ID获取需求选项
export function getDemandOptions(sid, did) {
  return request({
    url: '/data/knowledge_mapping/demand_options',
    method: 'get',
    params: { sid, did }
  })
}

// 根据结构ID和指标ID获取指标选项
export function getIndicatorOptions(sid, iid) {
  return request({
    url: '/data/knowledge_mapping/indicator_options',
    method: 'get',
    params: { sid, iid }
  })
}

// 根据结构ID获取所有选项型或范围型需求
export function getOptionOrRangeDemands(sid) {
  return request({
    url: '/data/knowledge_mapping/option_demands/' + sid,
    method: 'get'
  })
}

// 根据结构ID获取所有选项型技术指标
export function getOptionIndicators(sid) {
  return request({
    url: '/data/knowledge_mapping/option_indicators/' + sid,
    method: 'get'
  })
}

// 批量添加知识映射
export function batchAddKnowledgeMapping(data) {
  return request({
    url: '/data/knowledge_mapping/batch',
    method: 'post',
    data: data
  })
}

// 根据结构ID删除知识映射
export function removeKnowledgeMappingByStructId(structId) {
  return request({
    url: '/data/knowledge_mapping/struct/' + structId,
    method: 'delete'
  })
}

// 根据需求ID删除知识映射
export function removeKnowledgeMappingByDemandId(demandId) {
  return request({
    url: '/data/knowledge_mapping/demand/' + demandId,
    method: 'delete'
  })
}

// 根据指标ID删除知识映射
export function removeKnowledgeMappingByIndicatorId(indicatorId) {
  return request({
    url: '/data/knowledge_mapping/indicator/' + indicatorId,
    method: 'delete'
  })
}

// 根据需求选项ID获取已映射的技术指标
export function getIndicatorMappingsByDemandId(doid) {
  return request({
    url: '/data/knowledge_mapping/indicator_mappings/' + doid,
    method: 'get'
  })
}

// 根据技术指标选项ID获取已映射的需求
export function getDemandMappingsByIndicatorId(ioid) {
  return request({
    url: '/data/knowledge_mapping/demand_mappings/' + ioid,
    method: 'get'
  })
}

// 根据结构ID获取知识映射结果
export function getKnowledgeMappingResultsBySid(sid) {
  return request({
    url: '/data/knowledge_mapping/mapping_results/' + sid,
    method: 'get'
  })
}

// 根据需求选项ID和技术指标选项ID获取映射关系
export function getKnowledgeMappingsByDemandAndIndicator(doid, ioid) {
  return request({
    url: '/data/knowledge_mapping/by_demand_indicator',
    method: 'get',
    params: { doid, ioid }
  })
}

// 根据结构ID、需求ID和指标ID获取知识映射
export function getKnowledgeMappingsByStructAndDemandAndIndicator(params) {
  return request({
    url: '/data/knowledge_mapping/getByStructAndDemandAndIndicator',
    method: 'get',
    params: params
  });
}

// 根据需求选项ID获取知识映射结果 - 统一API路径
export function getKnowledgeMappingResultsByDoid(doid) {
  return request({
    url: '/data/knowledge_mapping/getByDoid/' + doid,
    method: 'get'
  })
}